<script setup>
import { hotList } from '@/hooks/hot.js'
import { defineEmits } from 'vue'
import { useRouter } from "vue-router"

const router = useRouter()
const emit = defineEmits(["search"])

const hotItemClick = (item) => {
  if (item.kindId === 0) {
    router.push(`/scenicspot/${item.businessId}`)
  } else if (item.kindId === 2) {
    router.push(`/hotel-detail/${item.businessId}`)
  } else if (item.kindId === 3) {
    router.push(`/hotpot/${item.businessId}`)
  }
}

</script>

<template>
  <div class="hot" v-if="hotList.length">
    <div class="header">
      <div class="content">
        <img class="icon" src="@/assets/images/icons/Subtract.png" alt="">
        <h2>热门搜索</h2>
      </div>
      <img class="bg_img" src="@/assets/images/index/Rectangle217.jpg" alt="">
    </div>
    <ul class="hot_list">
      <li @click="hotItemClick(item)" class="list" v-for="(item, index) in hotList" :key="index">
        <div :class="[index < 3 ? 'hot_index' : '', 'index']">{{index + 1}}</div>
        <span class="name">{{ item.keyword }}</span>
      </li>
    </ul>
  </div>
</template>

<style scoped lang="scss">
.hot{
  background: #FFFFFC;
  border-radius: 1rem;
  box-shadow: 0 1.2rem 2rem 0 rgba(2,95,38,0.05);
  opacity: 1;
  margin: 0 1.5rem 3rem 1.5rem;
  padding-bottom: 1rem;
  .header{
    position: relative;
    height: 4rem;
    .content{
      position: absolute;
      z-index: 2;
      display:flex;
      align-items: center;
      height: 100%;
      padding: 0 1rem;
      .icon{
        width: 1.6rem;
        height: 1.6rem;
      }
      h2{
        padding-left: .5rem;
        font-size: 1.4rem;
        font-weight: bold;
        color: #FFFFFF;
      }
    }
    .bg_img{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 1;
    }
  }
  .hot_list{
    .list{
      display: flex;
      align-items: center;
      height: 4rem;
      font-size: 1.4rem;
      .index{
        width: 2rem;
        height: 2rem;
        border-radius: .3rem;
        opacity: 1;
        text-align: center;
        line-height: 2rem;
        margin-left: 1rem;
        font-weight: bold;
        background: rgba(0,0,0,0.05);
        color: #999999;
      }
      .hot_index{
        background: linear-gradient(177deg, #43D19D 0%, #FFF29F 94%);
        color: #FFFFFF;
      }
      .name{
        font-weight: bold;
        color: #333333;
        padding-left: .8rem;
      }
    }
  }
}
</style>